package com.ruoyi.web.controller.pollution;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.PageUtil;
import com.ruoyi.common.utils.PageUtils;
import com.ruoyi.pollution.service.IKeySupervisedEnterprisesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 重点监管企业Controller
 */
@RestController
@RequestMapping("/KeySupervisedEnterprises")
public class KeySupervisedEnterprisesController extends BaseController {
    @Autowired
    private IKeySupervisedEnterprisesService keySupervisedEnterprisesService;


    /**
     * 重点企业监管超标分析
     *
     * @param startTime endTime  时间
     *                  countyCode  县
     *                  polluteName  企业名称
     * @return
     */
    @GetMapping("/getoverdataforenterprise")
    public TableDataInfo getOverDataForEnterprise(String CountyCode, String polluteName, String startTime, String endTime) {
        startPage();
        List<Map<String, Object>> dataList = keySupervisedEnterprisesService.getExceedingCountByPollute(startTime, endTime, CountyCode, polluteName);
        return getDataTable(dataList);
    }
    /**
     * 企业超标详情
     */
    @GetMapping("/getEnterpriseDetail")
    public TableDataInfo getEnterpriseDetail(String polluteId, String beginTime, String endTime, Integer pageNum, Integer pageSize) {
        List<Map<String, Object>> list = keySupervisedEnterprisesService.getEnterpriseDetail(polluteId, beginTime, endTime);
        List<Map<String, Object>> retList = PageUtil.startListPage(list, pageNum, pageSize).getList();
        return getDataTable(retList);
    }

    /**
     * 异常统计-企业
     *
     * @param startTime endTime  时间
     *          countyCode  县
     *          polluteName  企业名称
     * @return
     */
    @GetMapping("/getExceptionCountByenterprise")
    public AjaxResult getExceptionCountByPollute(String CountyCode, String polluteName, String startTime, String endTime) {
        List<Map<String, Object>> dataList = keySupervisedEnterprisesService.getExceptionCountByPollute(startTime, endTime, CountyCode, polluteName);
        return AjaxResult.success(dataList);
    }

    /**
     * 异常企业详情
     */
    @GetMapping("/getExceptionEnterpriseDetail")
    public TableDataInfo getExceptionEnterpriseDetail(String polluteId,String dataType,String beginTime,String endTime,Integer pageNum,Integer pageSize) {
       List<Map<String,Object>> list= keySupervisedEnterprisesService.getExceptionEnterpriseDetail( polluteId, dataType, beginTime, endTime);
        List<Map<String,Object>> retList= PageUtil.startListPage(list,pageNum,pageSize).getList();
        return getDataTable(retList);
    }
}
